<?php
require dirname(__FILE__).'/function.php';

function file_get_contents_post($url, $post) {
    $options = array(
        'http' => array(
            'method' => 'POST',
            // 'content' => 'name=caiknife&email=caiknife@gmail.com',
            'content' => http_build_query($post),
        ),
    );

    $result = file_get_contents($url, false, stream_context_create($options));

    return $result;
}

$data = file_get_contents_post("http://localhost/phplearn/postmethod/post.php", array('name'=>'caiknife', 'email'=>'caiknife@gmail.com'));

var_dump($data);

//测试方法
//http://localhost/phplearn/postmethod/post_file.php